<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <p>vue实例的生命周期钩子函数</p>
    <input type="text" v-model="msg">
  </div>
  <script src="../vue.js"></script>
  <script>
    let vm = new Vue({
      el: '#app',
      data: {
        msg: 'hello'
      },
      beforeCreate() {
        console.log('beforeCreate:实例创建前');
        console.log(this.msg);
        console.log(this.$el);
        this.showNum()
        console.log('----------------------');
      },
      created() {
        // 用的很多，发送ajax请求一般在这里调用
        console.log('created:实例创建后');
        console.log(this.msg);
        console.log(this.$el);
        this.showNum()
        console.log('----------------------');
      },
      beforeMount() {
        console.log('beforeMount:页面渲染前');
        console.log(this.msg);
        console.log(this.$el);
        this.showNum()
        console.log('----------------------');
      },
      mounted() {
        console.log('mounted:页面渲染后');
        console.log(this.msg);
        console.log(this.$el);
        this.showNum()
        console.log('----------------------');
      },
      beforeUpdate() {
        console.log('beforeUpdate：更新前');
        console.log(this.msg);
        console.log(this.$el);
        console.log('----------------------');
      },
      updated() {
        console.log('updated：更新后');
        console.log(this.msg);
        console.log(this.$el);
        console.log('----------------------');
      },
      beforeDestroy() {
        console.log('beforeDestroy：销毁前');
        console.log(this.msg);
        console.log(this.$el);
        console.log('----------------------');
      },
      destroyed() {
        console.log('destroyed：销毁后');
        console.log(this.msg);
        console.log(this.$el);
        console.log('----------------------');
      },
      methods: {
        showNum() {
          console.log(666);
        }
      },
    })
  </script>
</body>
</html>